package com.hang.controller;

import com.hang.common.Result;
import com.hang.service.AdminService;
import com.hang.service.StudentService;
import com.hang.service.TeacherService;
import com.hang.vo.FeedBackVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "管理员模块")
@RestController
@RequiredArgsConstructor
@RequestMapping("admin")
public class AdminController {
    private final TeacherService teacherService;
    private final StudentService studentService;
    private final AdminService adminService;

    @PostMapping("importTeacher")
    @ApiOperation(value = "导入老师信息")
    public Result importTeacherInfo(@RequestParam("file") MultipartFile multipartFile){
        teacherService.insertInformation(multipartFile);
        return Result.ok();
    }

    @PostMapping("importStudent")
    @ApiOperation(value = "导入学生信息")
    public Result importStudentInfo(@RequestParam("file") MultipartFile multipartFile){
        studentService.insertInformation(multipartFile);
        return Result.ok();
    }

    @PostMapping("importClazz")
    @ApiOperation(value = "导入班级信息")
    public Result importClazzInfo(@RequestParam("file") MultipartFile multipartFile){
        adminService.insertInformation(multipartFile);
        return Result.ok();
    }

    @PostMapping("feedback")
    @ApiOperation(value = "提交反馈意见")
    public Result feedback(
        @RequestBody FeedBackVo feedBackVo
    ){
        Map<String,Object> map = adminService.feedBack(feedBackVo);
        return Result.ok(map);
    }
}